#ifndef HISTORYMODEL_H
#define HISTORYMODEL_H

#include <QObject>
#include <QAbstractListModel>
#include <QMutex>
#include "Warning_Mid.h"
class HistoryModel : public QAbstractListModel
{
    Q_OBJECT


public:
    static HistoryModel *getInstance();


    enum WarningRoles {
        StartDateRole = Qt::UserRole + 1,
        StartTimeRole,
        DescriptionRole,
        EndTimeRole,
        DurationRole
    };


    int rowCount(const QModelIndex &parent = QModelIndex()) const override;

    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

    QHash<int, QByteArray> roleNames() const override;


public slots:
    void updateHistory(const QVector<WarningInfo> &newHistory);

    void updateWarning(const WarningInfo &info);



private:
    HistoryModel(QObject *parent = nullptr);
    ~HistoryModel();
    HistoryModel(const HistoryModel&)=delete;
    HistoryModel &operator=(const HistoryModel)=delete;

    static HistoryModel* m_instance;
    static QMutex m_mutex;

     QVector<WarningInfo> m_warningList;


signals:
};

#endif // HISTORYMODEL_H
